/*
 * Author  : Pallab
 * Program : 1303
 *
 * 2012-02-16 13:58:39
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

int n; // number if people;
int m; // number of ferry seat
int full;
inline void Read() {
    scanf("%d %d",&n,&m);
    full = 1<<m;
    --full;
}
int f[25];
int p[25];
deque< int > q;
inline int OR(int msk, int i) {
    return msk|(1<<i);
}
inline int AND(int msk, int i) {
    return ( msk&(1<<i) ) ;
}
inline void update(int seat) {
    fo(i,SZ(q)) {
        int _p = q[i];
        int msk = p[ _p ];
        if ( AND(msk,seat) ) continue;
        q.erase(q.begin()+i);
        p[_p] = OR( msk, seat );
        f[seat]=_p;
        break;
    }
}

inline bool done() {
    foE(i,1,n) {
        if ( p[i]!=full )return false;
    }
    fo(i,m) {
        if ( f[i] )return false;
    }
    return true;
}
inline void Proc() {
    SET(p,0);
    SET(f,0);
    q.clear();

    foE(i,1,n) {
        q.pb(i);
    }
    int t=0;
    for (int seat=0; !done() ;t+=5 ) {
        if ( f[ seat ] ) {
            // nambe akjon
            q.pb( f[seat] );
            f[seat]=0;
        }
        update( seat ) ;
        ++seat;
        if (seat==m) {
            seat=0;
        }
    }
    cout<<t;
    puts("");
}
int main() {
    int tt;
    CI(tt);
    foE(i,1,tt) {
        Read();
        cout<<"Case "<<i<<": ";
        Proc();
    }
    return 0;
}
// kate: indent-mode cstyle; space-indent on; indent-width 0; 


